//  program:	TVs and polarization
//  task:       *run models--replication file
//				project: Cameras and Polarization
// 				Related files: 
//  author:     Josh Ryan \ December 4, 2024

// #Start
// program setup

set more off
set seed 123456789


*set working directory

use "chamber_level_forstata_v4_102524.dta", clear

describe

replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro)

*Table A2: Descriptive Statistics of Variables Used in the Models, also loads legislator-level data
**Outcomes
sum late_budget
sum budget_kurtosis
sum diffs
sum dem_sd
sum rep_sd
sum billprop

use "leg_level_forstata_v6_102524.dta", replace

describe

drop if party_id==3
replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro) 

sum np_score if party_id==0
sum np_score if party_id==1
sum sles
sum party_loyalty

*Controls
use "chamber_level_forstata_v4_102524.dta", clear

replace total_intro=ln(total_intro) 

sum veto
sum mds1
sum mds2
sum state_ideo
sum citizen_ideo
sum ranney
sum lngsp
sum tl
sum lnexp
sum lnpop
sum total_intro

use "leg_level_forstata_v6_102524.dta", replace
drop if party_id==3

sum party_id 
sum majority




use "chamber_level_forstata_v4_102524.dta", clear

describe

replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro)
 
*Table B1: Main Results: TThe Effect of Broadcast/Streamed Floor Coverage on State Legislative Outcomes

*late budget
eststo est1a:  xtlogit late_budget treatment i.year, fe vce(boot)

eststo est1b:  xtlogit late_budget treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(boot)

*Budget Kurtosis
eststo est2a: reghdfe budget_kurtosis treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est2b: reghdfe budget_kurtosis treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intr, absorb(state_cham year) vce(cluster state_cham year)

*Distance between party medians
eststo est3a: reghdfe diffs treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est3b: reghdfe diffs treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Democratic Intra Party SD
eststo est4a: reghdfe dem_sd treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est4b: reghdfe dem_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Republican intra party SD
eststo est5a: reghdfe rep_sd treatment, absorb(state_cham year) vce(cluster state_cham year) 

eststo est5b: reghdfe rep_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Legislative Productivity
eststo est6a: reghdfe billprop treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est6b: reghdfe billprop treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

estout est1a est1b est2a est2b est3a est3b  est4a est4b est5a est5b est6a est6b, style(tex) cells(b(star fmt(2)) se(par)) starlevels($^\#$ .1 * 0.05) stats(aic N r2) ///
varlabels(treatment "Adoption of Floor Coverage" veto "Total No. of Bills/Resolutions Vetoed in State-Year" mds1 "Leg. Prof. 1st Dimensional Scaling" mds2 "Leg. Prof. 2nd Dimensional Scaling" state_ideo "State Ideology" ranney "Political Competition" lngsp "Gross State Product (Logged)"  tl "State Term Limits (1=Yes)" lnexp "Logged Legislative Expenditures" citizen_ideo "Citizen Ideology" lnpop "State Population (Logged)" total_intro "Logged No. of Bills Introduced" _cons "Constant")


*Figure 1: Estimated Chamber-Level Coefficients From Diff.-in-Diff. Analysis}

*Right Panel: Late Budget
grstyle init
grstyle set plain, horizontal grid dotted
*grstyle set ci burd, select(11 13) opacity(60)
coefplot (est1b, label(Late Budget)), drop(_cons veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro *.year ) ///
yline(0) vertical xlabel(none) ylabel(-3(.5)3, valuelabel) ///
ytitle("Estimated Coefficient of Adoption")  ///
 legend(on) legend(region(lstyle(none))) ///
scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) title() yscale(titlegap(5))
graph save logit_treat, replace

*Left Panel, all others
grstyle init
grstyle set plain, horizontal grid dotted
*grstyle set ci burd, select(11 13) opacity(60)
coefplot (est2b, label(Budget Kurtosis)) ///
(est3b, label(Inter-party Polarization)) (est4b, label("Democratic Intra-party" "Polarization")) (est5b, label("Republican Intra-party" "Polarization")) (est6b, label(Legislative Productivity)), drop(_cons veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro *.year ) ///
yline(0) vertical xlabel(none) ylabel(-.1(.02).1, valuelabel) ///
ytitle("Estimated Coefficient of Adoption" )  ///
 legend(on)  legend(region(lstyle(none))) ///
scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) title() yscale(titlegap(5))
graph save regression_treat, replace

graph combine logit_treat.gph regression_treat.gph, scale(.75) scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) col(2)

use "chamber_level_forstata_v4_102524.dta", clear

describe

replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro)

*Table B2: The Effect of Broadcast/Streamed Floor Coverage on State Legislative Outcomes Accounting for Possible Post-Treatment Variables
*robustness check without possible post-treatment variables
*Row 2: Removing possible post-treatment variables
xtlogit late_budget treatment  mds1 mds2 state_ideo ranney lngsp tl  citizen_ideo lnpop  i.year, fe vce(boot)

*Budget Kurtosis
reghdfe budget_kurtosis treatment  mds1 mds2 state_ideo ranney lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)

*Distance between party medians
reghdfe diffs treatment mds1 mds2 state_ideo ranney lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)

*Democratic Intra Party SD
reghdfe dem_sd treatment mds1 mds2 state_ideo ranney lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)

*Republican intra party SD
reghdfe rep_sd treatment mds1 mds2 state_ideo ranney lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)

*Legislative Productivity
reghdfe billprop treatment mds1 mds2 state_ideo ranney lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)

*Row 3: Lagged variables
sort state_cham year 
by state_cham: gen lveto =l.veto
by state_cham: gen lmds1 =l.mds1
by state_cham: gen lmds2 =l.mds2
by state_cham: gen lstate_ideo =l.state_ideo
by state_cham: gen lranney =l.ranney
by state_cham: gen llngsp =l.lngsp
by state_cham: gen ltl =l.tl
by state_cham: gen llnexp =l.lnexp
by state_cham: gen lcitizen_ideo =l.citizen_ideo
by state_cham: gen llnpop =l.lnpop
by state_cham: gen ltotal_intro =l.total_intro


*Late Budget
xtlogit late_budget treatment lveto lmds1 lmds2 lstate_ideo lranney llngsp ltl llnexp lcitizen_ideo llnpop ltotal_intro i.year, fe vce(boot)

*Budget Kurtosis
reghdfe budget_kurtosis treatment lveto lmds1 lmds2 lstate_ideo lranney llngsp ltl llnexp lcitizen_ideo llnpop ltotal_intro, absorb(state_cham year) vce(cluster state_cham year)

*Distance between party medians
reghdfe diffs treatment lveto lmds1 lmds2 lstate_ideo lranney llngsp ltl llnexp lcitizen_ideo llnpop ltotal_intro, absorb(state_cham year) vce(cluster state_cham year)

*Democratic Intra Party SD
reghdfe dem_sd treatment lveto lmds1 lmds2 lstate_ideo lranney llngsp ltl llnexp lcitizen_ideo llnpop ltotal_intro, absorb(state_cham year) vce(cluster state_cham year)

*Republican intra party SD
reghdfe rep_sd treatment lveto lmds1 lmds2 lstate_ideo lranney llngsp ltl llnexp lcitizen_ideo llnpop ltotal_intro, absorb(state_cham year) vce(cluster state_cham year)

*Legislative Productivity
reghdfe billprop treatment lveto lmds1 lmds2 lstate_ideo lranney llngsp ltl llnexp lcitizen_ideo llnpop ltotal_intro, absorb(state_cham year) vce(cluster state_cham year)


*ROW 4
*estimate full model 2. then use pretreatment only as controls in second stage, subtract effect of post-treatment, reestimate
reg late_budget treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.state_cham i.year, vce(cluster state_cham)
gen ytilde = late_budget - _b[veto] - _b[total_intro] - _b[lnexp]
reg ytilde treatment mds1 mds2 state_ideo lngsp tl citizen_ideo lnpop i.state_cham i.year, vce(cluster state_cham)
drop ytilde

reghdfe budget_kurtosis treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)
gen ytilde = budget_kurtosis - _b[veto] - _b[total_intro] - _b[lnexp]
reghdfe ytilde treatment mds1 mds2 state_ideo lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)
drop ytilde

reghdfe diffs treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)
gen ytilde = diffs - _b[veto] - _b[total_intro] - _b[lnexp]
reghdfe ytilde treatment mds1 mds2 state_ideo lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)
drop ytilde

reghdfe dem_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)
gen ytilde = dem_sd - _b[veto] - _b[total_intro] - _b[lnexp]
reghdfe ytilde treatment mds1 mds2 state_ideo lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)
drop ytilde

reghdfe rep_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)
gen ytilde = rep_sd - _b[veto] - _b[total_intro] - _b[lnexp]
reghdfe ytilde treatment mds1 mds2 state_ideo lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)
drop ytilde

reghdfe billprop treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)
gen ytilde = billprop - _b[veto] - _b[total_intro] - _b[lnexp]
reghdfe ytilde treatment mds1 mds2 state_ideo lngsp tl citizen_ideo lnpop, absorb(state_cham year) vce(cluster state_cham year)
drop ytilde




*Table B4: The Effect of Broadcast/Streamed Floor Coverage on State Legislative Outcomes Using ``Clean" Adoption States 
use "chamber_level_forstata_v4_102524.dta", clear

describe

replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro)
order state_cham

*oregon- 71 and 72, michigan 43 and 44,NH 57 and 58, TX--NO SOME BROADCAST, MS 49 AND 50, VA SENATE, NO SOME BROADCAST, IL 27 AND 28, AR HOUSE 5 ADN 6, MO 47 AND 48, MA UNCLEAR Excluded, PA 73 AND 74, MD 39 AND 40, NM UNCLEAR EXCLUDED, AZ 7 and 8, MT 51 and 52, WV Senate 96, House Unknown, Iowa House 23, Iowa Senate 24, Oklahoma House and Senate 69 and 70, OR House and Senate, RI House and Senate 75 and 76,LA House 35, WA House and Senate, VA House and Senate  PLUS those that never adopted, MO Senate 48, NC Senate 54, SD House and Senate 79 and 80
*20 state chambers for 860 observations
keep if state_cham==71 | state_cham==72 | state_cham==43 | state_cham==44 | state_cham==57 | state_cham==58 | state_cham==49 |state_cham==50 | state_cham==27 | state_cham==28 | state_cham==5 | state_cham==6 | state_cham==47 | state_cham==48 | state_cham==73 | state_cham==74 | state_cham==39 | state_cham==62 | state_cham==7 | state_cham==8 |state_cham==51 | state_cham==52 | state_cham==96 | state_cham==48 |state_cham==54 | state_cham==79 | state_cham==80 |state_cham==23 | state_cham==24 | state_cham==69 | state_cham==70 | state_cham==75 | state_cham==76 | state_cham==35 | state_cham==91 | state_cham==92 | state_cham==48 | state_cham==54 | state_cham==79 | state_cham==87 |state_cham==88

*Table Appendix B4--Main Results: The Effect of Broadcast/Streamed Floor Coverage on State Legislative Outcomes Using Clean Treatment States

eststo est1a:  xtlogit late_budget treatment i.year, fe vce(boot)

eststo est1b:  xtlogit late_budget treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year i.state_cham, vce(cluster state_cham) 

*Budget Kurtosis
eststo est2a: reghdfe budget_kurtosis treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est2b: reghdfe budget_kurtosis treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Distance between party medians
eststo est3a: reghdfe diffs treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est3b: reghdfe diffs treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Democratic Intra Party SD
eststo est4a: reghdfe dem_sd treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est4b: reghdfe dem_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Republican intra party SD
eststo est5a: reghdfe rep_sd treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est5b: reghdfe rep_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Legislative Productivity
eststo est6a: reghdfe billprop treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est6b: reghdfe billprop treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

estout est1a est1b est2a est2b est3a est3b  est4a est4b est5a est5b est6a est6b, style(tex) cells(b(star fmt(2)) se(par)) starlevels($^\#$ .1 * 0.05) stats(aic N r2) ///
varlabels(treatment "Adoption of Floor Coverage" veto "Total No. of Bills/Resolutions Vetoed in State-Year" mds1 "Leg. Prof. 1st Dimensional Scaling" mds2 "Leg. Prof. 2nd Dimensional Scaling" state_ideo "State Ideology" ranney "Political Competition" lngsp "Gross State Product (Logged)"  tl "State Term Limits (1=Yes)" lnexp "Logged Legislative Expenditures" citizen_ideo "Citizen Ideology" lnpop "State Population (Logged)" total_intro "Logged No. of Bills Introduced" _cons "Constant")



*Table B5: The Effect of Broadcast/Streamed Floor Coverage on State Legislative Outcomes Conditional on Legislative Professionalism and Term Limits

use "chamber_level_forstata_v4_102524.dta", clear

describe

replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro)
order state_cham

*Late Budget
eststo est1b:  xtlogit late_budget i.treatment##c.mds1 veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(boot)

eststo est1c:  xtlogit late_budget i.treatment##i.tl veto mds1 mds2 state_ideo ranney lngsp lnexp citizen_ideo lnpop total_intro i.year, fe vce(boot)
margins, at(treatment=(0 1) tl=(0 1))  post vsquish

*Budget Kurtosis
eststo est2b: reghdfe budget_kurtosis i.treatment##c.mds1 veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo est2c: reghdfe budget_kurtosis i.treatment##i.tl veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Distance between party medians
eststo est3b: reghdfe diffs i.treatment##c.mds1 veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo est3c: reghdfe diffs i.treatment##i.tl veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Democratic Intra Party SD
eststo est4b: reghdfe dem_sd i.treatment##c.mds1 veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo est4c: reghdfe dem_sd i.treatment##i.tl veto mds1 mds2 state_ideo ranney lngsp lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)
margins, at(treatment=(0 1) tl=(0 1))  post vsquish


*Republican intra party SD
eststo est5b: reghdfe rep_sd i.treatment##c.mds1 veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo est5c: reghdfe rep_sd i.treatment##i.tl veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Legislative Productivity
eststo est6b: reghdfe billprop i.treatment##c.mds1 veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo est6c: reghdfe billprop i.treatment##i.tl veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

estout est1b est1c est2b est2c est3b est3c est4b est4c est5b est5c est6b est6c, style(tex) cells(b(star fmt(2)) se(par)) starlevels($^\#$ .1 * 0.05) stats(aic N r2) ///
varlabels(treatment "Adoption of Floor Coverage" veto "Total No. of Bills/Resolutions Vetoed in State-Year" mds1 "Leg. Prof. 1st Dimensional Scaling" mds2 "Leg. Prof. 2nd Dimensional Scaling" state_ideo "State Ideology" ranney "Political Competition" lngsp "Gross State Product (Logged)"  tl "State Term Limits (1=Yes)" lnexp "Logged Legislative Expenditures" citizen_ideo "Citizen Ideology" lnpop "State Population (Logged)" total_intro "Logged No. of Bills Introduced" _cons "Constant")



*Figure 2
*****Null Effects analysis

use "chamber_level_forstata_v4_102524.dta", clear

describe

replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro)

*not shown because error is large, encompasses all plausible values

*late budget
*xtlogit late_budget treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, level(90) fe vce(boot)

*budget kurtosis
sum budget_kurtosis
reghdfe budget_kurtosis treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, level(90) absorb(state_cham year) vce(cluster state_cham year)

sum diffs
reghdfe diffs treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, level(90) absorb(state_cham year) vce(cluster state_cham year)

sum dem_sd
reghdfe dem_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, level(90) absorb(state_cham year) vce(cluster state_cham year)

sum rep_sd
reghdfe rep_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, level(90) absorb(state_cham year) vce(cluster state_cham year)

sum billprop
reghdfe billprop treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, level(90) absorb(state_cham year) vce(cluster state_cham year)

*graphs are in R file: 04_nulleffects_analysis_vx
*******


*Table C1: Predicting Change in Treatment Status Using Outcomes
*Parallel Trends check 1

use "chamber_level_forstata_v4_102524.dta", clear

describe

replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro)
order state_cham

eststo test1a: xtreg d.treatment late_budget i.year, fe vce(cluster state_cham)

eststo test1b: xtreg d.treatment late_budget veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(cluster state_cham)

eststo test2a: xtreg d.treatment budget_kurtosis i.year, fe vce(cluster state_cham)

eststo test2b: xtreg d.treatment budget_kurtosis veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(cluster state_cham)

eststo test3a: xtreg d.treatment diffs  i.year, fe vce(cluster state_cham)

eststo test3b: xtreg d.treatment diffs  veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(cluster state_cham)

eststo test4a: xtreg d.treatment dem_sd i.year, fe vce(cluster state_cham)

eststo test4b: xtreg d.treatment dem_sd veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(cluster state_cham)

eststo test5a: xtreg d.treatment rep_sd  i.year, fe vce(cluster state_cham)

eststo test5b: xtreg d.treatment rep_sd veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(cluster state_cham)

eststo test6a: xtreg d.treatment billprop i.year, fe vce(cluster state_cham)

eststo test6b: xtreg d.treatment billprop veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(cluster state_cham)

estout test1a test1b test2a test2b test3a test3b  test4a test4b test5a test5b test6a test6b, style(tex) cells(b(star fmt(2)) se(par)) starlevels($^\#$ .1 * 0.05) stats(aic N r2) ///
varlabels(treatment "Adoption of Floor Coverage" late_budget "Late Budget" budget_kurtosis "Budget Kurtosis" diffs "Inter-party Polarization" diffs "Inter-party Polarization" dem_sd "Democratic Intra-party Polarization" "rep_sd" "Republican Intra-party Polarization" billprop "Legislative Productivity" veto "Total No. of Bills/Resolutions Vetoed in State-Year" mds1 "Leg. Prof. 1st Dimensional Scaling" mds2 "Leg. Prof. 2nd Dimensional Scaling" state_ideo "State Ideology" ranney "Political Competition" lngsp "Gross State Product (Logged)"  tl "State Term Limits (1=Yes)" lnexp "Logged Legislative Expenditures" citizen_ideo "Citizen Ideology" lnpop "State Population (Logged)" total_intro "Logged No. of Bills Introduced" _cons "Constant")



*Table C2:  Predicting Lagged Treatment Status Using Outcomes
*Parallel Trends check 2

sort state_cham year
eststo test1a: xtlogit l.late_budget treatment i.year, fe vce(boot)

sort state_cham year
eststo test1b: xtlogit l.late_budget treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(boot)

sort state_cham year
eststo test2a: reghdfe l.budget_kurtosis treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo test2b: reghdfe l.budget_kurtosis treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo test3a: reghdfe l.diffs treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo test3b: reghdfe l.diffs treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo test4a: reghdfe l.dem_sd treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo test4b: reghdfe l.dem_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo test5a: reghdfe l.rep_sd treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo test5b: reghdfe l.rep_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

eststo test6a: reghdfe l.billprop treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo test6b: reghdfe l.billprop treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

estout test1a test1b test2a test2b test3a test3b  test4a test4b test5a test5b test6a test6b, style(tex) cells(b(star fmt(2)) se(par)) starlevels($^\#$ .1 * 0.05) stats(aic N r2) ///
varlabels(treatment "Adoption of Floor Coverage" late_budget "Late Budget" budget_kurtosis "Budget Kurtosis" diffs "Inter-party Polarization" diffs "Inter-party Polarization" dem_sd "Democratic Intra-party Polarization" "rep_sd" "Republican Intra-party Polarization" billprop "Legislative Productivity" veto "Total No. of Bills/Resolutions Vetoed in State-Year" mds1 "Leg. Prof. 1st Dimensional Scaling" mds2 "Leg. Prof. 2nd Dimensional Scaling" state_ideo "State Ideology" ranney "Political Competition" lngsp "Gross State Product (Logged)"  tl "State Term Limits (1=Yes)" lnexp "Logged Legislative Expenditures" citizen_ideo "Citizen Ideology" lnpop "State Population (Logged)" total_intro "Logged No. of Bills Introduced" _cons "Constant")



*********************
*Figure 3 and Table D1: Estimated Chamber-Level Treatment Effects Over Time
use "chamber_level_forstata_v4_102524.dta", clear

xthdidregress ra (late_budget) (treatment), group(state_cham)
estat aggregation, time graph

xthdidregress ra (budget_kurtosis) (treatment), group(state_cham)
estat aggregation, time graph

*out of order
xthdidregress ra (billprop) (treatment), group(state_cham)
estat aggregation, time graph

replace treatment=. if treatment==1 & year<1997
xthdidregress ra (diffs) (treatment), group(state_cham)
estat aggregation, time graph

xthdidregress ra (dem_sd) (treatment), group(state_cham)
estat aggregation, time graph

xthdidregress ra (rep_sd) (treatment), group(state_cham)
estat aggregation, time graph


*using TWFE rather than regression adjustment, not shown in paper, but discussed
/*
xthdidregress twfe (late_budget) (treatment), group(state_cham)
estat aggregation, time graph

xthdidregress twfe (budget_kurtosis) (treatment), group(state_cham)
estat aggregation, time graph

xthdidregress twfe (billprop) (treatment), group(state_cham)
estat aggregation, time graph

replace treatment=. if treatment==1 & year==1993
xthdidregress twfe (diffs) (treatment), group(state_cham)
estat aggregation, time graph

use "chamber_level_forstata_v4_102524.dta", clear

xthdidregress twfe (dem_sd) (treatment), group(state_cham)
estat aggregation, time graph

xthdidregress twfe (rep_sd) (treatment), group(state_cham)
estat aggregation, time graph
*/




*these data are loaded from a Stata file generated by the above code to create the graphs.
***note these are also in a different order than in the data, but in the same order as the paper, starting with late_budget

use "bacondecomp_time_aggregate.dta", clear

sum year if late_budget_heteffect==1
twoway rarea lci uci year if late_budget_heteffect==1, color(gs14) ///
ytitle("Estimated Coefficient of Adoption")  ///
legend(on) legend(region(lstyle(none))) ///
xlabel(1986(4)2018, valuelabel) ylabel(-1(.25)1, valuelabel) ///
xtitle("Year") ///
legend(order(1 "95% CI")) ///
yline(0) ///
scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) title("Late Budget")
graph save latebudget_heteffect.gph, replace

sum year if budget_kurtosis_heteffect==1
twoway rarea lci uci year if budget_kurtosis_heteffect==1, color(gs14) ///
ytitle("Estimated Coefficient of Adoption")  ///
legend(on) legend(region(lstyle(none))) ///
xlabel(1986(4)2018, valuelabel) ylabel(-1(.25)1, valuelabel) ///
xtitle("Year") ///
legend(order(1 "95% CI")) ///
yline(0) ///
scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) title("Budget Kurtosis")
graph save budgetkurtosis_heteffect.gph, replace

sum year if diffs_heteffect==1
twoway rarea lci uci year if diffs_heteffect==1, color(gs14) ///
ytitle("Estimated Coefficient of Adoption")  ///
legend(on) legend(region(lstyle(none))) ///
xlabel(1986(4)2018, valuelabel) ylabel(-1(.25)1, valuelabel) ///
xtitle("Year") ///
legend(order(1 "95% CI")) ///
yline(0) ///
scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) title("Inter-Party Polarization")
graph save diffs_heteffect.gph, replace

sum year if dem_sd_heteffect==1
twoway rarea lci uci year if dem_sd_heteffect==1, color(gs14) ///
ytitle("Estimated Coefficient of Adoption")  ///
legend(on) legend(region(lstyle(none))) ///
xlabel(1986(4)2018, valuelabel) ylabel(-1(.25)1, valuelabel) ///
xtitle("Year") ///
legend(order(1 "95% CI")) ///
yline(0) ///
scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) title("Dem. Intra-Party Polarization")
graph save dem_sd_heteffect.gph, replace

sum year if rep_sd_heteffect==1
twoway rarea lci uci year if rep_sd_heteffect==1, color(gs14) ///
ytitle("Estimated Coefficient of Adoption")  ///
legend(on) legend(region(lstyle(none))) ///
xlabel(1986(4)2018, valuelabel) ylabel(-1(.25)1, valuelabel) ///
xtitle("Year") ///
legend(order(1 "95% CI")) ///
yline(0) ///
scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) title("Rep. Intra-Party Polarization")
graph save rep_sd_heteffect.gph, replace

sum year if billprop_heteffect==1
twoway rarea lci uci year if billprop_heteffect==1, color(gs14) ///
ytitle("Estimated Coefficient of Adoption")  ///
legend(on) legend(region(lstyle(none))) ///
xlabel(1986(4)2018, valuelabel) ylabel(-1(.25)1, valuelabel) ///
xtitle("Year") ///
legend(order(1 "95% CI")) ///
yline(0) ///
scheme(s1mono) graphregion(fcolor(white) ifcolor(white)) title("Legislative Productivity")
graph save billprop_heteffect.gph, replace

graph combine latebudget_heteffect.gph budgetkurtosis_heteffect.gph diffs_heteffect.gph dem_sd_heteffect.gph rep_sd_heteffect.gph billprop_heteffect.gph, cols(2)  scale(.6) scheme(s1mono) graphregion(fcolor(white) ifcolor(white))



** Table D2: Bacon Decomposition of Difference-in-Difference Estimator
use "chamber_level_forstata_v4_102524.dta", clear

describe

*have to drop missing here
drop if treatment==.

*these have balanced panels with no missing--NOTE they are out of order in the table
xtdidregress (budget_kurtosis) (treatment), group(state_cham) time(year) vce(cluster state_cham)
estat bdecomp, summaryonly

xtdidregress (billprop) (treatment), group(state_cham) time(year) vce(cluster state_cham)
estat bdecomp, summaryonly

*there are missing in some places, need to obtain strongly balanced panel, drop some obs

tab state_cham year
drop if diffs==.

*drop if less than 23 as that is the typical number of observations
bysort state_cham: gen state_cham_freq = _N
bysort state_cham: egen state_cham_max = sum(state_cham_freq)
tab state_cham_freq
keep if state_cham_freq==23

xtdidregress (late_budget) (treatment), group(state_cham) time(year) vce(cluster state_cham)
estat bdecomp, summaryonly

xtdidregress (diffs) (treatment), group(state_cham) time(year) vce(cluster state_cham)
estat bdecomp, summaryonly

xtdidregress (dem_sd) (treatment), group(state_cham) time(year) vce(cluster state_cham)
estat bdecomp, summaryonly

xtdidregress (rep_sd) (treatment), group(state_cham) time(year) vce(cluster state_cham)
estat bdecomp, summaryonly


*panelmatch in R file 02panelmatch_balancetests_v2_011224 and 03panelmatch_analysis_v1_120823
*Figures 7, E1-E6 and E7.


*With slightly different year coding based on changes from recontact

*"New Mexico SENATE and house maybe"	2017?	2017--we spoke to different people and they were extremely unsure so we have low confidence this is correct
*Arizona 2006 2006
*Montana 2003 2003
*Louisiana Senate 2008


use "chamber_level_forstata_v4_102524.dta", clear

describe

replace veto=veto/100
replace citizen_ideo=citizen_ideo/100
replace state_ideo=state_ideo/100
replace total_intro=ln(total_intro)
 

replace treatment=0 if year<2006 & state=="AZ"
replace treatment=1 if year>2005 & state=="AZ"

replace treatment=0 if year<2003 & state=="MT"
replace treatment=1 if year>2002 & state=="MT"

replace treatment=0 if year<2017 & state=="NM"
replace treatment=1 if year>2016 & state=="NM"

replace treatment=0 if year<2008 & state=="LA" & Chamber=="Senate"


eststo est1a:  xtlogit late_budget treatment i.year, fe vce(boot)

eststo est1b:  xtlogit late_budget treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro i.year, fe vce(boot)

*Budget Kurtosis
eststo est2a: reghdfe budget_kurtosis treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est2b: reghdfe budget_kurtosis treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intr, absorb(state_cham year) vce(cluster state_cham year)

*Distance between party medians
eststo est3a: reghdfe diffs treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est3b: reghdfe diffs treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Democratic Intra Party SD
eststo est4a: reghdfe dem_sd treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est4b: reghdfe dem_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Republican intra party SD
eststo est5a: reghdfe rep_sd treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est5b: reghdfe rep_sd treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

*Legislative Productivity
eststo est6a: reghdfe billprop treatment, absorb(state_cham year) vce(cluster state_cham year)

eststo est6b: reghdfe billprop treatment veto mds1 mds2 state_ideo ranney lngsp tl lnexp citizen_ideo lnpop total_intro, absorb(state_cham year) vce(cluster state_cham year)

estout est1a est1b est2a est2b est3a est3b  est4a est4b est5a est5b est6a est6b, style(tex) cells(b(star fmt(2)) se(par)) starlevels($^\#$ .1 * 0.05) stats(aic N r2) ///
varlabels(treatment "Adoption of Floor Coverage" veto "Total No. of Bills/Resolutions Vetoed in State-Year" mds1 "Leg. Prof. 1st Dimensional Scaling" mds2 "Leg. Prof. 2nd Dimensional Scaling" state_ideo "State Ideology" ranney "Political Competition" lngsp "Gross State Product (Logged)"  tl "State Term Limits (1=Yes)" lnexp "Logged Legislative Expenditures" citizen_ideo "Citizen Ideology" lnpop "State Population (Logged)" total_intro "Logged No. of Bills Introduced" _cons "Constant")


